<template>
  <jc-bar prve-btn @prve="prve"></jc-bar>

  <v-container>
    <div style="width: 100%; height: calc(100vh - 85px)">
      <div
        class="d-flex justify-center flex-column align-center"
        style="position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); width: 320px"
      >
        <div
          style="
            width: 80px;
            height: 80px;
            background-color: #fff;
            padding: 10px;
            box-sizing: content-box;
            border-radius: 25px;
          "
        >
          <img style="width: 100%; height: 100%" :src="AppStarIcon" />
        </div>
        <div class="mt-4 text-title">版本号：{{ versionDetail?.version || "1.1.6" }}</div>
        <div class="my-4">
          <AppDowloadLink :androDownPath="androDownPath" />
        </div>
        <div class="mt-4 text-title text-lg" v-html="explain"></div>
      </div>
    </div>
  </v-container>
</template>
<script>
import AppDowloadLink from "@/components/AppDowloadLink.vue";
import JcBar from "@/layout/JcBar.vue";
import BackageContainer from "../../layout/BackageContainer.vue";
import AppStarIcon from "@/assets/ic_launcher.png";
import { getAppVersion } from "@/api/cloudbase-bbkz.js";
export default {
  name: "AppDownload",
  components: {
    JcBar,
    BackageContainer,
    AppDowloadLink,
  },
  data() {
    return {
      AppStarIcon,
      versionDetail: {},
    };
  },
  computed: {
    explain() {
      if (this.versionDetail.context) {
        const arr = this.versionDetail.context.split("\n");

        return arr.join("<br/>");
      }
      return "";
    },
    androDownPath() {
      return (
        this.versionDetail?.downpath || "https://project-star.oss-cn-beijing.aliyuncs.com/app/app-release1.1.6.apk"
      );
    },
  },
  mounted() {
    getAppVersion()
      .then((res) => {
        console.log("获取到的app版本", res.data);
        this.versionDetail = res.data;
      })
      .catch((err) => {
        console.log("err-->", err);
      });
  },
  methods: {
    prve() {
      this.$router.go(-1);
    },
  },
};
</script>
